package cn.fan.config.mq;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MSGDirectMessageConfig {
    @Bean
    public DirectExchange msgDirectExchange(){
        return new DirectExchange("msg.direct");
    }

    @Bean
    public Queue msgDirectQueue(){
        return QueueBuilder
                .durable("msg.queue")
                .ttl(10000)
                .deadLetterExchange("error.direct")
                .deadLetterRoutingKey("error")
                .build();
    }

    @Bean
    public Binding msgDirectBinding(){
        return BindingBuilder
                .bind(msgDirectQueue())
                .to(msgDirectExchange())
                .with("msg");
    }
}
